<template>
    <view class="container">
        <header-bar :config="config"></header-bar>
        <product-temp v-if="showData" :getTempCartData="getTempCartData" :tempType="2" @cutware="cutware"
            :valetUserInfo="valetUserInfo" :valetUserId="valetUserId" :warehouseId="warehouseId"
            :selectType="selectType" :isGift="isGift"></product-temp>
        <return-sales-cart v-if="valetUserId" :isShowCar="isShowCar" :valetUserId="valetUserId"
            :valetUserInfo="valetUserInfo" :warehouseId="warehouseId" :selectType="selectType"></return-sales-cart>
    </view>
</template>

<script>
import productTemp from "@/pages/product/productTemp.vue"
import returnSalesCart from "@/components/returnCart/return-sales-cart.vue"
import { getCarList } from "@/utils/valetCartUtil.js"
export default {
    components: {
        productTemp,
        returnSalesCart,
    },
    data() {
        return {
            config: {
                title: "代客下单",
                centerSlot: true,
                leftSlot: true,
                color: ["#ffffff"],
            },
            isOnShow: true,
            valetUserId: 0,
            warehouseId: 0,
            valetUserInfo: "",
            isShowCar: false,
            showData: false,
            isGift: false,
            getTempCartData: [],
            selectType: "",
        }
    },
    methods: {
        cutware(id) {
            this.warehouseId = id
            this.isOnShow = true
            this.showData = true
            getCarList(this.valetUserId, this.warehouseId, this.isGift).then((res) => {
                // this.getTempCartData = res
                this.$forceUpdate()
            })
        },
    },
    onLoad(e) {
        this.selectType = e.selectType || ""
        if (this.selectType == 3) {
            this.config.title = "报价下单"
        }
        if (this.selectType == 4) {
            this.config.title = "一客一价"
        }
        this.valetUserInfo = e.valetUserInfo
        this.valetUserId = Number(e.valetUserId)
        this.warehouseId = Number(e.warehouseId)
        let valetUserInfoObj = JSON.parse(decodeURIComponent(this.valetUserInfo))
        this.config.leftText = valetUserInfoObj.StoreName
        this.isShowCar = e.isShowCar
        this.isGift = e.isGift
        this.$forceUpdate()
    },
    created() {
        let mainColor = this.easyGetColor("main")
        this.mainColor = mainColor
        this.config.backgroundColor = [1, mainColor]
    },
    onShow() {
        this.isOnShow = true
        this.showData = true
        let isGift = this.isGift ? 1 : 0
        getCarList(this.valetUserId, this.warehouseId, isGift).then((res) => {
            // this.getTempCartData = res

            this.$forceUpdate()
        })
    },
    onHide() {
        // this.upCart(false)
    },
    computed: {},
}
</script>

<style lang="scss"></style>
